#pragma once


#include <IXMenuButton.h>
#include "XButtonImpl.h"
#include <IXMenuPre.h>

template <class I>
class CXMenuButtonImpl : public CXButtonImpl<I>
{
    typedef CXButtonImpl<I> superclass;

    BEGIN_DEF_SKIN_CLASS(CXMenuButton, superclass, gs_strGuidXSkin)
        IMP_BASIC_INTF(IXMenuButton,    0)
    END_DEF_SKIN_CLASS();

    IMPL_CONTROL_OBJ(CXMenuButtonImpl, superclass, _T("MenuButton"));

public:
    CXMenuButtonImpl();
    virtual ~CXMenuButtonImpl();

public:
    // IXMenuButton
    virtual BOOL STDMETHODCALLTYPE  put_ArrowImage(IN LPCTSTR szXNC, IN int nSubImageCount, IN int nArrowWidth);

    virtual BOOL STDMETHODCALLTYPE  put_Menu(IN IXMenuPre* pMenuPre, int nSubMenuIndex);

    virtual BOOL STDMETHODCALLTYPE  put_MenuId(IN int nMenuId, int nSubMenuIndex);
    virtual BOOL STDMETHODCALLTYPE  put_MenuName(IN LPCTSTR lpMenuName, int nSubMenuIndex);

    virtual BOOL STDMETHODCALLTYPE  put_MenuIdEx(IN int nMenuId, int nSubMenuIndex, IN HINSTANCE hInstance);
    virtual BOOL STDMETHODCALLTYPE  put_MenuNameEx(IN LPCTSTR lpMenuName, int nSubMenuIndex, IN HINSTANCE hInstance);

    virtual BOOL STDMETHODCALLTYPE  get_Menu(OUT IXMenuPre** ppMenuPre);

public:
    // IXBaseObj
    virtual void STDMETHODCALLTYPE   OnFinalRelease();

public:
    // IXFrame
    virtual void    STDMETHODCALLTYPE   GetAutoSize(OUT LPSIZE pAutoSize);
    virtual void    STDMETHODCALLTYPE   Draw(XCANVAS xCanvas, const RECT& rcDraw);

protected:
    // CXMenuButtonImpl
    void ReleaseData();

    // CXFrameImpl
    virtual BOOL    OnClicked(const POINT* pt);

protected:
    XPtr<IXMenuPre>    m_pMenuPre;
    int             m_nArrowWidth;
};


class CXMenuButton : public CXMenuButtonImpl<IXMenuButton>
{
};
